/**
 * 
 */
package model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.OneToMany;

/**
 * @author dga
 *
 */
@Entity()
public class Client extends Persistent {
  private String login;
  private String password;
  private List<Order> orders;
  
  public boolean equals(Object other){
    if(other != null && other instanceof Client)
        return getLogin().equals(((Client)other).getLogin());
    return false;
  }
  public int hashCode(){
    return getLogin().hashCode();
  }

  
  @Column(nullable = false, unique=true)
  public String getLogin() {
    return login;
  }
  public void setLogin(String login) {
    this.login = login;
  }
  public String getPassword() {
    return password;
  }
  public void setPassword(String password) {
    this.password = password;
  }

  @OneToMany(mappedBy="client",cascade ={CascadeType.PERSIST, CascadeType.REMOVE})
  public List<Order> getOrders() {
    return orders;
  }
  public void setOrders(List<Order> orders) {
    this.orders = orders;
  }

}
